package com.zzj.controller;

import com.github.pagehelper.PageInfo;
import com.zzj.bean.PlanBean;
import com.zzj.service.PlanService;
import com.zzj.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
//@CrossOrigin
@RequestMapping("plan")
@Api
public class PlanController {
    @Autowired
    private PlanService planService;

    @ApiOperation("获取所有的待补全计划")
    @GetMapping("find")
    public PageInfo<PlanBean> findByState(@RequestParam(defaultValue = "1") int pageNum,
                                          @RequestParam(defaultValue = "5") int pageSize){
        return planService.findByState(pageNum,pageSize,"0");
    }

    @ApiOperation("补全生产计划")
    @PutMapping("updatePlan")
    public Result updatePlan(@RequestBody PlanBean planBean){
        return planService.updatePlan(planBean);
    }

    @ApiOperation("获取所有的待补全计划")
    @GetMapping("findAll")
    public PageInfo<PlanBean> findAll(
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "5") int pageSize){
        return planService.findAll(pageNum,pageSize);
    }
}
